feat: Shows an alert in container sync if the only change is a local override to a text component [FC-0097]#2516
Conversation
|
Thanks for the pull request, @ChrisChV! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2516 +/- ##
========================================
Coverage 94.75% 94.75%
========================================
Files 1205 1206 +1
Lines 26949 26979 +30
Branches 6049 5907 -142
========================================
+ Hits 25535 25564 +29
- Misses 1344 1356 +12
+ Partials 70 59 -11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| const { data } = useCourseContainerChildren(downstreamBlockId, true); | ||
| let showLocalUpdateAlert = false; | ||
| let localUpdateAlertBlockName = ''; | ||
|
|
||
| // Show this alert if the only change is a local override to a text component | ||
| if (!isReadyToSyncIndividually && data?.upstreamReadyToSyncChildrenInfo.length === 1 | ||
| && data.upstreamReadyToSyncChildrenInfo[0].isModified | ||
| && data.upstreamReadyToSyncChildrenInfo[0].blockType === 'html') { | ||
| showLocalUpdateAlert = true; | ||
| localUpdateAlertBlockName = data.upstreamReadyToSyncChildrenInfo[0].name; | ||
| } | ||
|
|
There was a problem hiding this comment.
This section can be moved inside CompareContainersWidgetInner component and duplicate calls to useCourseContainerChildren api can be avoided. As we only want to fetch getUpstreamInfo at top level in diff preview, we can use parent.length==0 like so:
const { data, isError, error } = useCourseContainerChildren(downstreamBlockId, parent.length === 0);There was a problem hiding this comment.
@navinkarkera Thanks for the recommendation!
I decided not to put this in CompareContainersWidgetInner because if you enter a child, the alert would disappear. By keeping this call in CompareContainersWidget, the alert remains in the modal regardless of whether you navigate within the children. I will add comments about this. What do you think?
navinkarkera
left a comment
There was a problem hiding this comment.
@ChrisChV This looks good except for the issue with the logic of determining rename or content updates. I don't mind if you think we can fix it as part of another ticket.
| let state: ContainerState | undefined; | ||
| const displayName = oldVersion.upstreamLink.isModified ? oldVersion.name : newVersion.displayName; | ||
| let originalName: string | undefined; | ||
| const isRenamed = displayName !== newVersion.displayName && displayName === oldVersion.name; |
There was a problem hiding this comment.
This logic doesn't work when the content is updated locally and the upstream display name is updated. isRenamed becomes true.
We probably need to differentiate between contentModified and rename in the backend or send downstream_customized field to the frontend and use it here.
There was a problem hiding this comment.
I think we can fix it in a separate ticket; we are out of budget on this ticket. I will add a coment about that
| const { data } = useCourseContainerChildren(downstreamBlockId, true); | ||
| let showLocalUpdateAlert = false; | ||
| let localUpdateAlertBlockName = ''; | ||
|
|
||
| // Show this alert if the only change is a local override to a text component | ||
| if (!isReadyToSyncIndividually && data?.upstreamReadyToSyncChildrenInfo.length === 1 | ||
| && data.upstreamReadyToSyncChildrenInfo[0].isModified | ||
| && data.upstreamReadyToSyncChildrenInfo[0].blockType === 'html') { | ||
| showLocalUpdateAlert = true; | ||
| localUpdateAlertBlockName = data.upstreamReadyToSyncChildrenInfo[0].name; | ||
| } | ||
|
|
| // We decided not to put this in `CompareContainersWidgetInner` because if you enter a child, | ||
| // the alert would disappear. By keeping this call in CompareContainersWidget, | ||
| // the alert remains in the modal regardless of whether you navigate within the children. | ||
| if (!isReadyToSyncIndividually && data?.upstreamReadyToSyncChildrenInfo.length === 1 |
There was a problem hiding this comment.
@ChrisChV I missed this before, but this will only work if a single modified text component is ready to sync. I think we need to show this alert even if there are multiple text component (all locally modified) ready to sync no?
There was a problem hiding this comment.
In the issue I have not seen mentioned in plural, it is always in singular, but I have asked the question: #2438 (comment)
There was a problem hiding this comment.
Updated to support multiple text components with local overrides: 1afbcda
navinkarkera
left a comment
There was a problem hiding this comment.
@ChrisChV Great work 👍
- I tested this: (Verified alert behaviour)
- I read through the code
- I checked for accessibility issues
- Includes documentation
bradenmacdonald
left a comment
There was a problem hiding this comment.
This is a lot of special-case code, so I hope we can remove or simplify it in the future. But the code itself is fine, my concern is more with the spec.
Just a couple nits that are optional.
|
Thanks; go ahead and merge anytime. |
- Shows an alert in container sync if the only change is a local override to a text component [FC-0097] (openedx#2516) - Implements the alert described in openedx#2438 (comment)
Description
Supporting information
Testing instructions
Other information
Merge this before the Ulmo cut
Best Practices Checklist
We're trying to move away from some deprecated patterns in this codebase. Please
check if your PR meets these recommendations before asking for a review:
.ts,.tsx).propTypes,defaultProps, andinjectIntlpatterns are not used in any new or modified code.src/testUtils.tsx(specificallyinitializeMocks)apiHooks.tsin this repo for examples.messages.tsfiles have adescriptionfor translators to use.../. To import from parent folders, use@src, e.g.import { initializeMocks } from '@src/testUtils';instead offrom '../../../../testUtils'